import {createReducer, on, Action} from '@ngrx/store';

import {MemberState, ModalTypes} from '../../data-types/store/member-reducer.interface';
import * as Actions from '../actions/member.action';

export const initialState: MemberState = {
  modalVisible: false,
  modalType: ModalTypes.Default
};

const reducer = createReducer(
  initialState,
  on(Actions.SetModalType, (state, { modalType }) => ({...state, modalType})),
  on(Actions.SetModalVisible, (state, { modalVisible }) => ({...state, modalVisible})),
);

export const memberReducer = (state: MemberState, action: Action) => {
  return reducer(state, action);
};
